package pqt;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Toolkit;

public class Excentricidad extends JDialog {

	private final JPanel contentPanel = new JPanel();
	int veces = 0;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			Excentricidad dialog = new Excentricidad();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public Excentricidad() {
		setIconImage(Toolkit.getDefaultToolkit().getImage(Excentricidad.class.getResource("/img/icono.png")));
		setTitle("Excentricidad");
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		setBounds(100, 100, 842, 591);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBackground(new Color(204, 204, 204));
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		final JLabel labelTexto = new JLabel("");
		labelTexto.setFont(new Font("Tahoma", Font.PLAIN, 40));
		labelTexto.setBounds(10, 11, 806, 156);
		contentPanel.add(labelTexto);
		labelTexto.setText("<html><p align='center'>Coloque pesa de XXXX gramos en el <b>cuadrante 1</b> y oprima OK una vez que el equipo este estable</p></html>");
		
		final JLabel lblNewLabel = new JLabel("");
		lblNewLabel.setIcon(new ImageIcon("D:\\Facultad\\Tesis\\img\\cuadrante1.png"));
		lblNewLabel.setBounds(203, 197, 420, 224);
		contentPanel.add(lblNewLabel);
		
		final JButton btnOk = new JButton("");
		btnOk.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				if(veces == 0)
					{TablaExcentricidad tabla = new TablaExcentricidad();
				tabla.setLocationRelativeTo(null);
				tabla.setModal(true);
				tabla.setVisible(true);
				veces++;
				}
				else
				{
					dispose();
				}
				
			}
		});
		
		
		
		contentPanel.add(btnOk);
		btnOk.setFocusable(true);
		btnOk.setContentAreaFilled(false);
		btnOk.setBorderPainted(false);
		btnOk.setBorder(null);
		btnOk.setBounds(291, 392, 265, 87);
		btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkAzulGrande.png")));
		btnOk.setPressedIcon(new ImageIcon(testBoton.class.getResource("/img/OkBlancoGrande.png")));
		btnOk.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseEntered(MouseEvent arg0) {
				btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkVerdeGrande.png")));
				getRootPane().setDefaultButton(btnOk);
				
			}
			@Override
			public void mouseExited(MouseEvent e) {
				btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkAzulGrande.png")));
				getRootPane().setDefaultButton(null);
			}
		});
		btnOk.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent arg0) {
				btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkVerdeGrande.png")));
				getRootPane().setDefaultButton(btnOk);
			}
			@Override
			public void focusLost(FocusEvent e) {
				btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkAzulGrande.png")));
				getRootPane().setDefaultButton(null);
			}
		});
		contentPanel.add(btnOk);
	}

}
